import info.gridworld.actor.Actor;
import info.gridworld.actor.Critter;
import info.gridworld.actor.Flower;
import info.gridworld.actor.Rock;
import info.gridworld.grid.Grid;
import info.gridworld.grid.Location;

import java.awt.Color;
import java.util.ArrayList;

public class KingCrab extends CrabCritter {
    public void processActors(ArrayList<Actor> actors) {
        Grid<Actor> grid = getGrid();
        Location present = getLocation();
        for (Actor tmp : actors) {
            if (tmp instanceof Flower || tmp instanceof Rock)
                tmp.removeSelfFromGrid();
            else {
                int dir = present.getDirectionToward(tmp.getLocation());
                Location loc = tmp.getLocation().getAdjacentLocation(dir);
                if (grid.isValid(loc) && grid.get(loc) == null) {
                    tmp.moveTo(loc);
                } else {
                    tmp.removeSelfFromGrid();
                }

            }
        }
    }
}
